<?php

namespace app\api\controller;

use app\api\model\Dealer as DealerModel;

/**
 * 分销控制器
 * Class Goods
 * @package app\api\controller
 */
class Dealer extends Controller
{
    //排行榜类型
    protected $typeArr = [
         1 => 'week',
         2 => 'month',
         3 => 'total',
         4 => 'team',
    ];


    /**
     * 获取分销排行榜
     * @return array
     * @throws \app\common\exception\BaseException
     * @throws \think\exception\DbException
     */
    public function getDealerOrderRank()
    {
        // 整理请求的参数
        $type = isset($this->typeArr[$this->request->param("type")]) ? $this->typeArr[$this->request->param("type")] : 'week';
        $force = !empty($this->typeArr[$this->request->param("force")]) ? $this->typeArr[$this->request->param("force")] : false;

        $DealerModel = new DealerModel();
        $rank = $DealerModel->getRankData($type,$force);

        if($rank){
            return $this->renderSuccess($rank);
        }
        return $this->renderError('获取失败');
    }























}
